<?php
//
//	file: includes/acp/acp_advmsg_boxes.php
//	begin: 10/07/2006
//	$Author: christopher $
//	$Revision: 28 $
//	$Date: 2008-01-28 23:55:41 +0000 (Mon, 28 Jan 2008) $
//	license: http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL)
//
//	description: Admin-level create/delete/edit pm boxes (i.e. universal boxes or group boxes).
//		Create/delete/edit user-specific boxes in UCP.

if ( !defined('IN_PHPBB') )
{
	die('Hack attempt');
}

$cp_title = 'Advmsg_boxes';
$cp_title_explain = 'Advmsg_boxes_explain';

// no fields in form : end there
if ( empty($fields) )
{
	// send "no options" with left side menus
	$cp_panels->display_empty();
	return;
}

class attach_config_auto_form extends auto_form
{
	function update_table(&$form_fields)
	{
		global $config, $db;
		global $attach_config;

		if ( empty($form_fields) )
		{
			return;
		}
		$keys = array();
		$db->sql_stack_reset();
		foreach ( $form_fields as $name => $value )
		{
			$keys[] = $db->sql_escape_string($name);
			$fields = array(
				'config_name' => $name,
				'config_value' => $value,
			);
			$db->sql_stack_statement($fields);
		}
		$sql = 'DELETE FROM ' . ATT_CONFIG_TABLE . '
					WHERE config_name IN(\'' . implode('\', \'', $keys) . '\')';
		$db->sql_query($sql, false, __LINE__, __FILE__);
		$db->sql_stack_insert(ATT_CONFIG_TABLE, false, __LINE__, __FILE__);

		// recache config
		$attach_config->read(true);

		// send achievement message
		message_return('Attach_config_updated', $this->return_msg, $config->url($this->requester, $this->return_parms, true));
	}
}

// instantiate the form
$parms = array(
	'mode' => $menu_id,
	'sub' => $subm_id == $menu_id ? '' : $subm_id,
	'ctx' => $ctx_id == $subm_id ? '' : $ctx_id,
);
$form = new attach_config_auto_form($attach_config->data, $fields, $cp_requester, 'Click_return_' . $subm_id, $cp_parms + $parms);
$form->process();
$template->set_switch('form');
$template->set_filenames(array('body' => 'cp_generic.tpl'));

?>